package ${innerTransferUtilPackagePath};

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.util.Assert;
import com.alibaba.fastjson.JSON;
import java.lang.reflect.Constructor;

@Slf4j
public class InnerTransferUtil {
    public static <T> T transferBean(Object src, Class<T> z) {
        Assert.notNull(src, "转化对象不能为null!");
        try {
            Constructor<T> noArgsCon = z.getConstructor();
            T t = noArgsCon.newInstance();
            BeanUtils.copyProperties(src, t);
            return t;
        } catch (Exception e) {
            log.error("转化对象出错！src：" + JSON.toJSONString(src), e);
            throw new RuntimeException("转化对象出错！src：" + JSON.toJSONString(src), e);
        }
    }
}
